# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=hOpenPGP
pkgname=haskell-hopenpgp
pkgver=2.9.8
pkgrel=149
pkgdesc="Native Haskell implementation of OpenPGP (RFC4880)"
url="http://floss.scru.org/hOpenPGP/"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-aeson' 'haskell-asn1-encoding' 'haskell-attoparsec'
         'haskell-base16-bytestring' 'haskell-bifunctors' 'haskell-bz2' 'haskell-binary-conduit'
         'haskell-conduit' 'haskell-conduit-extra' 'haskell-cryptonite'
         'haskell-crypto-cipher-types' 'haskell-errors' 'haskell-hashable'
         'haskell-incremental-parser' 'haskell-ixset-typed' 'haskell-lens' 'haskell-memory'
         'haskell-monad-loops' 'haskell-nettle' 'haskell-network-uri'
         'haskell-openpgp-asciiarmor' 'haskell-prettyprinter' 'haskell-resourcet' 'haskell-split'
         'haskell-time-locale-compat' 'haskell-unliftio-core' 'haskell-unordered-containers'
         'haskell-zlib')
makedepends=('ghc' 'haskell-quickcheck' 'haskell-quickcheck-instances' 'haskell-tasty'
             'haskell-tasty-hunit' 'haskell-tasty-quickcheck')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('2d4ccf9af498b0ec33d353fa891b555109318dc5f0c5be5eb4165ff88115efcd79d4d28a89909cd224abfd64ddc3e332c07b59e3202c9dbccabd70405c78edfa')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -fnetwork-uri
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
    cd $_hkgname-$pkgver
    runhaskell Setup test --show-details=direct
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
